<script>
	export default {
		onLaunch: function() {
			console.log('App Launch')
			this.checkLogin()
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		},
		methods: {
			checkLogin() {
				// 检查是否已登录
				const token = uni.getStorageSync('token')
				console.log('App启动时检查token:', token)
				
				// 获取当前页面
				const pages = getCurrentPages()
				if (pages.length > 0) {
					const currentPage = pages[pages.length - 1]
					const route = currentPage.route
					console.log('当前页面:', route)
					
					// 如果没有token且不在登录页，则跳转到登录页
					if (!token && route !== 'pages/login/login') {
						uni.reLaunch({
							url: '/pages/login/login'
						})
					}
				}
			}
		}
	}
</script>

<style>
	/*每个页面公共css */
</style>
